package com.yan.springbootstudy.service;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.yan.springbootstudy.dao.TestDataMapper;

/**
 * 
 * @Title: TestService.java
 * @Package com.yan.springbootstudy.service
 * @Description: 测试service类
 * @author yan
 * @date 2017年8月29日
 * @version V1.0
 */
@Service
@Transactional
public class TestService implements ITestService {

	@Resource
	JdbcTemplate jdbcTemplate; 
	
	@Resource
	TestDataMapper testDataMapper;
	
	@Override
	public int insertTestData() {
//		String insertSql = "INSERT INTO T_YANTEST01(COLUMN1,COLUMN2) VALUES(?,?)";
//		Object[] params = new Object[]{"column1","column2"};
//		return jdbcTemplate.update(insertSql, params);
		return testDataMapper.insertTestData("newcolumn1", "newcolumn2");
	}

	@Override
	public List<Map<String,Object>> getTestData() {
//		String selectSql = "SELECT DATAKEY, COLUMN1,COLUMN2, DATE_FORMAT(DBVERSION,'%Y-%m-%d %H:%i:%s')  AS DBVERSION FROM T_YANTEST01";
//		return jdbcTemplate.queryForList(selectSql);
		return testDataMapper.getTestData();
	}

	@Override
	public int updateTestDataById(String datakey) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int deleteTestDataById(String dataKey) {
		// TODO Auto-generated method stub
		return 0;
	}

}
